home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / mgr / sparcmgr / demo2.zoo / demo / ex / TODO / text0001.txt < prev    next >
Encoding:
Text File  |  1984-06-11  |  31.5 KB  |  619 lines

  1. Here's Mark Horton's reply to my letter on bugs
  2.  
  3. >From mark@cbosgd.UUCP Thu Jul 28 14:38:55 1983
  4.  
  5. Sorry this has taken so long, but your note was too long to digest
  6. in the cracks between the other stuff I do.  Anyway, you've clearly
  7. put a great deal of thought into this, and I appreciate your input.
  8. I'll reply individually to your thoughts, and keep them on file
  9. for use (someday) when vi gets rewritten.  Some of them are just
  10. plain bugs that ought to be fixed soon anyway.
  11.  
  12.     PROBLEMS WITH COUNTS
  13.  
  14.          The most gross case of misbehavior is that of N^B!
  15.     The effect is to redraw the screen 23N-44 lines further advanced.
  16.     (Probably the numbers depend on the screen-size of the terminal;
  17.     this is on a Z19, using termcap h19u.)  When N=1, this does indeed
  18.     move you a screenful backward, but for higher N it moves the window
  19.     forward some amount!  Further, whatever controls are supposed to
  20.     monitor whether the command would land one at an acceptable line-
  21.     number seem to have a different idea of what it is doing:  If you
  22.     aren't already familiar with these weird effects, try setting the
  23.     cursor near the end of a file that is more than 4 screenfuls long,
  24.     and hitting 3^B.  (You might then try an insert at the place you get
  25.     to, and a :f^] .)
  26. This is a known bug, and was fixed in 3.8.  The count is supposed to subtract
  27. (LINES-1)*N from the line number, but there's + that should be a -, so it
  28. goes forward instead.  The check is correct, so it's possible to go off
  29. the end of the buffer.
  30.          N/pattern/ would be useful, but is not allowed.
  31. N/pattern/ resets the window size (silly but true) to N.
  32.          ND would be a natural synonym for dN$, by analogy with NC for cN$,
  33.     but it doesn't work that way; it just ignores the N.
  34.          Finally, if N is precisely the number of lines
  35.     from the current line to the end of the file,  N$  will still correctly
  36.     carry one to the last character of the file, but cN$, NC, dN$ and yN$
  37.     refuse to do anything!  (NY does work, not being a synonym for yN$.)
  38.     The failure of NC is particularly annoying; often when I am composing
  39.     something, I go back to somewhere in the middle of the next-to-
  40.     last line, say, and want to rewrite the rest of the sentence;
  41.     2cc would kill not only the part I want to rewrite but also the OK
  42.     beginning of the line, and 2C or 2c$ won't work.  I realize that I
  43.     could get around this by keeping an empty line at the end of the file,
  44.     but that should not be necessary.
  45. While you're making valid observations here, are you aware that you can delete
  46. the current sentence with d} ?  I think that's what you really want.
  47.  
  48.  
  49.     PROBLEMS REGARDING SOURCE, MACROS, MAPPINGS
  50.          These are enormously useful, but seem to have all kinds of hidden
  51.     restrictions.
  52.  
  53.          The Appendix to the Ex Reference Manual, "List of Changes from
  54.     Version 3.5 to Version 3.6" says ``A bug which prevented the source
  55.     command from working...from visual has been fixed''.  It is true that
  56.     one can now use  :so  from vi, but it still has a bug:  When
  57.     the scriptfile invoked contains a global command
  58.     and some other command(s) after it, everything after the first global
  59.     command is ignored.  The same appears to be true of scripts in named
  60.     buffers invoked from vi-bottom-line by  @x.
  61. Sounds like a bug.
  62.  
  63.          (It is, perhaps, unexpected that one can invoke scripts with
  64.     multiline commands using @x from vi's bottom-line at all, since such
  65.     commands will not work if typed on vi's bottom line directly.
  66.     A script like
  67.         s/$/a\
  68.         b
  69.     invoked as @x will indeed work.  But strangely, if one tries to
  70.     invoke from the regular mode of vi the script
  71.         :s/$/a\
  72.         b
  73.     by putting it in buffer x and doing  @x, only the first line
  74.     will take effect.)
  75. In 3.7 (or 3.8, I'm not sure), you can say
  76.     :s/$/a^V^Mb
  77. to get a newline on the RHS.  Of course, this doesn't mean there isn't
  78. a bug in scripts.
  79.      
  80.          Another serious restriction is that the command ``vi'' appears to
  81.     be ignored in sourced ex-scripts, and though the command Q in macros of
  82.     various flavors in vi (mapped characters, map!ed characters that contain
  83.     ``...^V^[...Q...'';  @x scripts) does take one into ex, any ex
  84.     commands after it are ignored.
  85. The internals of getting a character from the tty are completely different
  86. in ex and vi.  Pushing input for one doesn't affect the other.  So there
  87. isn't much hope of changing this situation.
  88.      
  89.          I assume you are aware of whatever restrictions lead to the
  90.     error-message ``Cannot yank inside global/macro'', since you must
  91.     have written it, though ``inside'' seems to here have the peculiar
  92.     meaning ``after a text-changing operation of the macro.''
  93.          The error-message ``Can't undo in global commands'' is more
  94.     mysterious, since I get it when I have a global command after
  95.     a text-changing command in an @x script (though not in a sourced file).
  96.          Anyway, the fewer such restrictions these operations were subject
  97.     to, the more useful they would be!
  98. It's the way undo is done - the text for undo is saved in the "last deleted"
  99. buffer, and yank puts text there too.  Couple this with the fact that globals
  100. and macros can be undone as a unit (they save their state before the first change)
  101. and you'll see that the two notions can't coexist.  Of course, you can always
  102. yank into a named buffer, even inside a macro.
  103.  
  104.          Although nested source commands are allowed (and I find them
  105.     useful), they leave the editor in a ``noprompt'' state.  This
  106.     can be gotten around by including ``se prompt'' as a line in the
  107.     outermost scriptfile, but I would hope the problem causing it could
  108.     be cured.
  109. Bug, I guess.
  110.  
  111.          When one tries to ``:unmap!'' a ``:map!'' command whose
  112.     right-hand-side begins with ^H (entered as ^V^H, of course), one
  113.     gets the message ``That macro wasn't mapped''.  (One can get around
  114.     this by using :unmap! ^V[character].)
  115. Bug, I guess.
  116.  
  117.          Certain termcaps apparently produce automatic mappings, which
  118.     unfortunately may interfere with useful vi commands.  In particular,
  119.     on a tvi, ^L gets mapped to a movement command, which makes it
  120.     unavailable for redrawing the screen, unless unmapped.
  121. Well, there's no way for vi to tell the difference between ^L that the
  122. user typed as ^L and ^L that the user typed as right arrow.  However, there
  123. are a number of terminals that are upward compatible with the adm3a and use
  124. ^L for right arrow.  Vi has a special case for these built in - if the
  125. terminal has insert/delete line, and ^L is right arrow, then ^R will redraw
  126. the screen.
  127.  
  128.  
  129.     PROBLEMS WITH DIAGNOSTICS
  130.  
  131.     "Hit return to continue" -- It took me a long time to realize that
  132.     when I got this diagnostic there was an alternative to hitting
  133.     return.  I suggest it be reworded
  134.         "Hit Return or :"
  135.     However, the behavior of the editor when this diagnostic is given
  136.     seems to be inconsistent.  In particular, when the last of a serious
  137.     of commands is
  138.         :e otherfile
  139.     and I get "Hit return to continue", then hitting : usually
  140.     has no different effect from hitting return (or any other
  141.     key), namely the screen is redrawn; yet I think that sometimes
  142.     in this situation it has brought me directly to the bottom line
  143.     as desired.  Very confusing.
  144.          Would it be possible to have other alternatives than : and return
  145.     available, such as /pattern ?  Or, more simply, when one would presently
  146.     be given the diagnostic "Hit return to continue", why not just put the
  147.     editor into the state it would have if one then hit :, since one would
  148.     then still have the option of hitting return and getting into vi
  149.     proper, but it would not require the extra keystroke : to
  150.     begin a bottom-line command, nor would one go through the frequent
  151.     frustrating experience of absentmindedly starting to write a
  152.     bottom-line command, or a pattern-search, and then having to wait
  153.     while the screen was redrawn because one had hit a key other than :.
  154. There is an internal difference between "ex mode" (where it doesn't keep a
  155. screen image) and "vi mode" (where it does).  Any : command that outputs more
  156. than 1 line puts you into "ex mode", requiring "hit return to continue"
  157. before clearing the screen and redrawing it with known stuff.  There is no
  158. hope of this changing - the code is too spaghetti-ized already.  In the worst
  159. case, the ! command scribbles on the screen and there's nothing vi can do
  160. to know what the command did.
  161.  
  162. What you really want is for vi to check for typeahead and avert the refresh
  163. when it's going to have to redo it anyway.  My curses does this, but I simply
  164. don't have time to rewrite vi to use it.  This would also solve the other
  165. problem you mention where macros ought to redraw the screen only once.
  166. If you saw the insides of the code, you'd see it needs a rewrite to do this.
  167. Each command knows the screen things to do to fix the screen.
  168.  
  169. What most of us do is hit DEL when the screen is being drawn with something
  170. we don't want to see.  This aborts the update and leaves junk on the screen.
  171. Then you move the cursor where you want it, and if the screen is still
  172. garbaged, hit ^L.  Ugly but effective.
  173.  
  174.     "Using open mode"
  175.     Again, it took me a long time to learn that when I tried to enter
  176.     vi and got this diagnostic, it meant that the system had somehow
  177.     lost the termcap for the terminal I was on, and that I would have
  178.     to do something to get the correct termcap into the environment.
  179.     Till I realized this, I generally ended up either struggling along
  180.     frustrated in open mode, or logging out and logging back in.  I suggest
  181.     that when someone calls for vi and the termcap is not appropriate,
  182.     the editor should not be invoked in any form, but instead, a message
  183.     be given such as:
  184.          ``Your environment does not show a termcap entry permitting
  185.     the use of the visual editor.  If you are working on a terminal not
  186.     supporting vi (in particular, a device with no addressable cursor),
  187.     you may enter one of the other modes of the editor with the command
  188.     "open filename" or "ex filename".  If you are working on a terminal
  189.     that should support vi, your environment entries are incorrect and
  190.     should be corrected.  They presently show:
  191.          TERM=....
  192.          TERMCAP=....
  193.     If you know the correct name or abbreviation for your terminal-
  194.     type, type it at the end of the next line; if not hit return:
  195.          % setenv TERM ''
  196.          If the user typed an acceptable terminal-name, the message would
  197.     continue, telling how to get the appropriate termcap.  If the user
  198.     instead typed return, the message would ask him or her to type the
  199.     name of the manufacturer shown on the terminal, not
  200.     worrying about upper/lower-case distinctions, and a list of possible
  201.     terminal names and abbreviations would be given... .  This whole
  202.     program would not be part of the editor, so there would
  203.     be no problem of space within the existing crowded confines of
  204.     the editor code.
  205. This, of course, doesn't belong in vi, but in login or tset.  In fact,
  206. tset is much friendlier these days.  Vi will print a better diagnostic
  207. if it knows you're on a "generic" terminal type such as "dialup" - in
  208. terminfo there's a capability to indicate this, so it can print
  209.     I don't know what kind of terminal you have - all I have is "patchboard"
  210. 3.7 can't do this because it can't tell the difference between a generic
  211. terminal and a hardcopy terminal.
  212.  
  213.     "No such file or directory" -- I think there should be a distinction
  214.     between these two cases, because of the important distinction in the
  215.     consequences when the user tries to quit the editor:
  216. The kernel doesn't distinguish, so it's hard for vi to.  This is just a perror
  217. string.
  218.     If the directory exists, the file is created, but
  219.     if not, the results are more complicated -- I seem to recall on one
  220.     occasion simply losing what I had written on my second try
  221.     at quitting; though I just now did an experiment and this time
  222.     repeated ZZ's and :x's simply gave repeated error messages.
  223. Well, if it can't be reproduced, it doesn't stand much chance of getting fixed.
  224. (Not that it would if you could reproduce it, of course.)
  225.  
  226.     "File already exists..." -- The ``List of changes from 3.5 to 3.6'' says
  227.     ``If you get I/O errors, the file is considered "not edited"... .''
  228.     I presume that this correction is somehow the cause of the fact that
  229.     I frequently get the above message when trying to leave the editor
  230.     on a machine with version 3.7, and have to use
  231.           :w! %|q
  232. Ick!  Most of us just type
  233.     :wq!
  234. which is equivalent and much shorter.
  235.     to exit.  But I've never seen any evidence that there were I/O errors;
  236.     it mainly seems to happen when I've written some lines to another
  237.     file in the process of editing.  So the criteria the editor is using
  238.     to decide when there have been ``I/O errors'' should be rechecked.
  239. Actually, if you get ANY error (e.g. :foo<cr>) it resets the "buffer modified"
  240. condition.  I have finally been convinced this is not right.  For a while, I
  241. considered it a necessary evil in case your /tmp/Ex* file got an I/O error.
  242.  
  243.     "no such command from open/visual" -- This confused me in my first
  244.     few days of using the editor, when I didn't understand that one
  245.     couldn't use i and a (in either their vi or ex senses) from the bottom
  246.     line of vi.  A message "i -- no such command from open/visual"
  247.     was perplexing because I knew that "i" was indeed a vi command.
  248.     Perhaps it should say  "no such command from open/visual bottom line".
  249. OK.
  250.  
  251.     MISCELLANEOUS PROBLEMS
  252.  
  253.          In ex search and replacement patterns, \\ is supposed to represent
  254.     a real \-character, but something goes wrong when this occurs
  255.     at the end of a global command.  E.g., though
  256.          :s/^/\\
  257.     works OK (in vi or ex), the variant
  258.          :.g/^/s//\\
  259.     definitely does not.  In vi it turns everything off, in ex it seems to
  260.     behave as though there were just a single \, and in a scriptfile,
  261.     it -- does something still different, which you can discover if you
  262.     don't know!
  263. Backslash is special at the end of a line in global.  You need more \\'s.
  264.  
  265.     The Ex Reference Manual says, ``For sanity with use from within
  266.     visual mode, ex ignores a ":" preceding any command.''  But it
  267.     ignores it in the wrong place! -- not at the beginning of the
  268.     command line, but just before the command letter itself.  I.e.,
  269.     it accepts 1,3:s/^/     /, but not :1,3s/^/    /.
  270. Hmm.
  271.  
  272.     SUGGESTIONS FOR MINOR ADDED CAPABILITIES
  273.  
  274.        In a multiline substitute command with the "c" option, when
  275.     each line is displayed one has three choices: y, n or break.  There
  276.     are some further options that would be useful.  One would be "p" --
  277.     at present, "p" can only be included on the command line, which
  278.     means that one has a choice between seeing the result of every
  279.     substitution or none.  In practice, one would generally like to see
  280.     the results of the first few cases to make sure that the command one has
  281.     written does what one meant it to, and maybe a few tricky cases that
  282.     come up; but not every case!   Another might be "u" -- to undo the last
  283.     case for which one gave a "y".  Still another might be an option that
  284.     would mean ``undo the "c" option -- I see that the substitute command
  285.     is doing what I wanted, go ahead and finish it without me.''
  286. If I were going to do something this involved (I didn't know anybody used the
  287. c option anymore - most people use "n" and "." in vi) I would do query-replace
  288. ala EMACS right.
  289.         In a command  g/pattern/p,  the pattern in question is occasionally
  290.     such that it takes a while to figure out where on the line it occurs.
  291.     For this purpose, an option that ``pointed out'' the instance of the
  292.     pattern, in the same manner that the pattern to be replaced is pointed
  293.     out in substitute command with option c, would be desirable.
  294.         When  g/pattern/p  gives more than a screenful of lines, it would
  295.     be nice to have it piped through the equivalent of ``more''.
  296. Nice but unlikely.  Unless, of course, you have page mode in your tty driver,
  297. like we do, in which case you get it for free.
  298.  
  299.         ex has the command line option "-", which ``is useful in processing
  300.     editor scripts''.  But if one wants to use a script in the course of
  301.     an otherwise interactive editing session, it would be desirable to have
  302.     a corresponding resettable option ``:se -'' (or ``:se nofb'').
  303. Seems like a good idea.
  304.  
  305.          In strings in pattern-searches, it would be useful to have
  306.     ^ and $ retain their ``magic'', so that /x[a$]/ could
  307.     search for all occurrences of  x  before an  a  or a newline.
  308.     (Of course, one would then have to decide whether  /x[^y]/ should
  309.     include the case of  x  followed by a newline or not.)
  310. This sounds pretty hard to do.
  311.  
  312.         Just as ex allows the command :vi, so I think that vi should
  313.     have some bottom-line command equivalent to the regular-mode
  314.     command  Q.  When one has done some text-changing bottom-line
  315.     commands, and realizes one wants to go into ex, it can be time-
  316.     consuming to hit return and then Q, and wait for the screen to be
  317.     redrawn for vi before one gets the ex prompt.
  318. This would be ugly, since the ex command routine would have to return an
  319. indication to the vi routine to exit back to the top level ex command.
  320. But I suppose it could be done.
  321.  
  322.          The option of putting several commands on one line, separated
  323.     by, "|" is particularly useful in the vi bottom-line mode, because
  324.     it avoids having the screen redrawn several times.  It would be
  325.     useful to be able sometimes do the same thing with non-bottom-line
  326.     commands, e.g. in editing a troff file at a low baud rate on a dumb
  327.     terminal one might like to be able to do  i\fI^]3Ea\fR^]  without
  328.     watching the line get redrawn twice.  Perhaps some key that would
  329.     cause any sequence of commands to be ``held'' until some complementary
  330.     key was hit would be useful.
  331.          It would also be desirable to have a sequence of commands that had
  332.     been given in this way available as one unit to be repeated by ``.'',
  333.     if desired.
  334. See above.  And get yourself a terminal with insert/delete char!
  335.  
  336.          The parenthesis-matching facility with % might be extended
  337.     to match ` with ' and <  with  >.
  338. OK.
  339.  
  340.          I will mention one facility that I discovered by surprize is
  341.     possessed by  ed  but not  ex  --  sequences such as  \1  can be used
  342.     within  ed  search-patterns.  E.g. (for the most trivial case)
  343.          /\(.\)\1/
  344.     will search for doubled letters.
  345. This surprises me.
  346.  
  347.  
  348.     DEBATABLE SUGGESTIONS
  349.          I will mention here some possible changes which have the
  350.     difficulty that they would change the meaning of existing commands,
  351.     so that it could be argued that the disadvantage of users having
  352.     to change their habits might outweigh the advantages.
  353.  
  354.          First, one might try to resolve, one way or another, the
  355.     contradiction between the count arguments taken by the join commands
  356.     in  vi and  ex:  In ex, jN joins N+1 lines; in vi, NJ joins N lines
  357.     (except if N=1).
  358. Yeah, ex should be N, not N+1.
  359.  
  360.          Second, the movement commands  tx  and  Tx  of vi (x any character)
  361.     seem poorly defined.  Just as fx will ignore the character on which
  362.     the cursor is presently sitting, even if it is an  x,  and move to the
  363.     next occurrence, so I would think that  tx  should ignore the character
  364.     immediately after the cursor, and  Tx  the character immediately before
  365.     the cursor.  The point is that when one does  Nfx,  and finds that one
  366.     had failed to count one occurrence of  x  and fallen short of where one
  367.     wanted to go, one can hit  ;  and get there.  Likewise, on doing  Ntx
  368.     and finding one has fallen short, one should be able to hit  ;  and get
  369.     to the the next occurrence; but at present, hitting  ;  leaves
  370.     the cursor in the same position; one must hit  ``2;''  to get any
  371.     further.  In effect,  Ntx  is presently defined as  Nfxh;  I am
  372.     suggesting that it be defined as  lNfxh.
  373. Agreed.
  374.  
  375.          The sequences  cw, dw  and  yw  are presently violations of the
  376.     principle that  c[movement],  d[movement]  and  y[movement]  change,
  377.     delete, or yank everything from the current cursor position through
  378.     the endpoint of the movement command.  cw does what one would expect of
  379.     ce (in fact, they seem to be synonyms), while there is no way to get
  380.     the effect which  cw  would have if it were treated ``consistently''.
  381.     (E.g., if I have a line beginning  ``And if'', and I want to change it
  382.     to ``If'', I cannot just put the cursor on the A and hit  cwI^].)  dw
  383.     and  yw  delete up to the character immediately before the point to
  384.     which ``w'' would take the cursor.  I would have to agree that this
  385.     behavior of dw and  yw  is more useful than that which a literal
  386.     interpretation of the movement rule would lead to; but perhaps it
  387.     would become still more useful if when applied to the last word on
  388.     a line, it deleted or yanked the space immediately before the word
  389.     along with the word... .  On the other hand, one could argue for
  390.     making a distinction between  cw  and  ce.
  391. This is to make the user interface friendlier, and is a fact of life.
  392. If I wanted to change "And if" to "If", I'd type "dw~".
  393.  
  394.          Though I see the motivation for the above definitions,
  395.     I see no sensible reason why  Y  should be equivalent to  yy,  when
  396.     C  and  D  are equivalent to  c$  and  d$.  I would vote for changing
  397.     Y  to mean  y$.  
  398. The users wouldn't stand for such a change.  Too many are used to it like it is.
  399. But you could always map it.
  400.  
  401.     RADICAL SUGGESTIONS
  402.  
  403.          Is there any reason for maintaining the distinction between
  404.     the ``:'' state of vi, and  ex  itself?  At present, there are
  405.     relative advantages that lead one to choose to go into one or the
  406.     other for a given operation:  From the vi-: state, it is easier
  407.     to return to the regular vi state; from ex, one has a more powerful
  408.     range of commands; and it is easier to give a series of commands
  409.     because each carriage-return gives one a new prompt.  My suggestion
  410.     is that from vi, ``:'' should carry you directly to ex, and when you
  411.     are in ex, carriage-return (^M) after a command should give you a new
  412.     prompt, while ^] should put you into vi.  Conceivably, things might be
  413.     simplified even further, and carriage return rather than : could
  414.     be the key that would carry one from the regular mode of vi into ex:
  415. The basic problem here is that if : put you into ex mode, you'd have to redraw
  416. the screen when you hit return.  The motivation for : commands is that you
  417. don't have to go through a conceptually hard mode change and wait for a
  418. screen redraw.
  419.  
  420.                  .-------.    .-------.
  421.         .-------. a,i... | basic |  ^M    |    |
  422.         |  vi   |<------ |     |----->|  ex    |<---.
  423.         | insert|     |   vi  |    |    |    |^M
  424.         |  mode | ------>|     |<-----| mode     | ---'
  425.         `-------'  ^]     |  mode |   ^]    |    |
  426.                  `-------'    `-------'
  427.  
  428.     (Of course, ^M presently has a meaning in vi, but
  429.     it has a synonym +.)  Clearly, there would also be no need for a
  430.     special "Hit return to continue" state.
  431.          I have not distinguished vi and open in the above diagram.
  432.     My idea here is that ^] would actually return you to either vi
  433.     or open, whichever you had last been in, and that to switch
  434.     to the other, you could enter ex and type vi^] or o^] respectively.
  435.     (Or you could type  vi^M, respectively o^M, and further ex commands,
  436.     and the mode would be saved for the next time you hit a ^].)  Or
  437.     alternatively, these could be made settable options: se visual
  438.     respectively se novisual.
  439.          Having gotten used to the editor as it now exists, I admit that
  440.     I feel uneasy about the above idea -- the sense of knowing that
  441.     I am ``still in vi'' when I hit :, and not that ``other land'' of ex, 
  442.     represents a kind of of orientation that it is disconcerting
  443.     to abandon.  But I can't see any logical disadvantage in making
  444.     such a change.  Can you?  Certainly, there would be things that
  445.     would have to be thought out, such as what happens to bottom-line
  446.     vi pattern-searches.  My thought would be that ``/'' from vi should
  447.     give :/ (i.e., put one in ex at the start of a pattern-search),
  448.     and ^] after a pattern-search should put one into vi at the appropriate
  449.     character on the line, in contrast to ^M after a pattern search,
  450.     which would leave one in ex at the appropriate line.  In general,
  451.     I think such changes would lead to greater simplicity and learnability
  452.     of the editor.
  453.          I would also hope that excursions between vi and ex and back
  454.     could be allowed in scriptfiles.  It might also be desirable for
  455.     ex to have, in addition to a concept of ``current line'', one of
  456.     ``current cursor position''... .
  457.  
  458.          Well, on to another subject.  One of the inconveniences I
  459.     found very vexing when first learning to use the editor was that
  460.     when in either vi insert mode, or ex/vi-bottom-line, it was very hard
  461.     to edit what I was doing.  Within insert mode the only ``editing''
  462.     I could do, without escaping, was with the three operations ^H,
  463.     ^W and the kill character.  And on a slow line with a dumb terminal,
  464.     escaping to make changes could be very time-consuming because large
  465.     parts of the screen would insist on being redrawn.  Perhaps some
  466.     other control-character could serve as
  467.     a modified escape, that allowed one to edit what one had entered
  468.     in the current insertion without having everything below it redrawn,
  469.     and then return to it.  Obviously, if carried to its logical
  470.     limit this idea could lead to ridiculous nests of
  471.     editing operations; but there would be no need to carry it to its
  472.     logical limit.
  473. Why not just get a terminal with insert char?  You're paying in performance
  474. for having an obsolete terminal.
  475.          Anyway, the problem of editing ex-style commands
  476.     was even worse, because there was no way to ``escape and
  477.     revise''.  I eventually learned enough to realize that the solution
  478.     was to edit complicated commands in another file and source it.
  479. This is a standard complaint about a moded editor.  It couldn't be fixed
  480. without taking away the property of ESC ending command lines.  Besides,
  481. allowing editing on the bottom line would really break a lot of code.
  482.     But it is sometimes very useful to have the text on which the
  483.     commands are to act in front of you when composing them (e.g., you can
  484.     yank and modify various pieces), which led to the variant of writing
  485.     command lines within the file I was editing, and then writing
  486.     those lines into another file and sourcing that, without ever leaving
  487.     the current file.  But this is distracting to deal with
  488.     when concentrating on the editing task itself, which led me
  489.     to divise a scriptfile which would handle the writing-to-another-file-
  490.     and-sourcing for me.  Or actually, several such files:  One for
  491.     single-line commands to be used essentially once; one for single-line
  492.     commands that I would want to use on the same file during various
  493.     editing sessions, and so would want to keep available in that
  494.     file, and one for multi-line commands (to be used once).  When
  495.     I first got the idea, I thought one scriptfile would be enough, and
  496.     I would call it ``do'', so that the command to execute a script I
  497.     had written in a file I was editing would be ``:so do''.  The
  498.     file it would write to and source would be ``do.again'', so that
  499.     if I wanted to reuse it, I could ``:so do.again''.  When I realized
  500.     the need for several versions, ``do'' became a directory.  Here,
  501.     for your amusement, are the three files.  (Re the lines ``se prompt'',
  502.     cf. my comment on that under PROBLEMS WITH SOURCE etc.):
  503.  
  504.       do/1  (for 1-time use of 1-line commands)
  505.         .w! ~/do/again
  506.         d
  507.         so #
  508.         se prompt
  509.  
  510.       do/1+  (like above, without deleting the command)
  511.         .w! ~/do/again
  512.         so #
  513.         se prompt
  514.  
  515.       do/:  (to use this, write a multi-line command script, put : at
  516.       the beginning of the first line, put the cursor on the last
  517.       line of the script, and then source the following:)
  518.         ?^:?s/:/
  519.         ,''w! ~/do/again
  520.         ,''d
  521.         so #
  522.         se prompt
  523.  
  524.     (I also created another version to use in case the script had
  525.     to have an internal line beginning with ``:'', so that this couldn't
  526.     unambiguously mark the beginning of the script.  This used
  527.     a line which explicitly specified the address-range of the script.
  528.     But I have never had a need for it, so I will not bother you with it.)
  529.         Finally, having gotten an account on a machine with a version 3
  530.     editor recently, I have divised still another way of doing this.  I
  531.     have put in my EXINIT the command
  532.  
  533.         'map ^A "ayy:@a^M'
  534.  
  535.     and now, gratifyingly, the single stroke ^A has essentially the effect
  536.     of ``:so do/1+''  -- except for the restrictions to which vi ``map''
  537.     commands are subject.  But I've only been using this for a
  538.     couple of weeks; so I have yet to learn how chafing those restrictions
  539.     will or won't be.
  540.          Anyway, it might be worth thinking about whether some of these
  541.     things that I've done with macros should be incorporated in some form
  542.     into the editor itself; or else whether these macros might be written
  543.     up in the documentation (or some tutorials) on the editor.
  544.  
  545.          Next subject: Complicated pattern-searches in long files
  546.     can be time-consuming.  I have seen the point mentioned
  547.     that if a pattern-description can be begun with "^",
  548.     this can speed up the search -- since the pattern-comparisons need
  549.     only be begun at beginnings of lines.  In some cases, this might
  550.     not be possible, but the user might be aware of some other
  551.     character or character-sequence in the search-pattern
  552.     that will occur relatively rarely in the file.  In such cases it would
  553.     be desirable if the user could specify one spot from which the pattern
  554.     search should start, working forward and backward from there, to
  555.     minimize false starts.  E.g., if for some reason one wants to
  556.     delete every word containing the letter m, the script
  557.         %s/[^ ]*m[^ ]*//
  558.     would become much less time-consuming if one could mark the point
  559.     at which to begin, say writing
  560.         %s/[^ ]*\!m[^ ]*//
  561.     so as to instruct the editor to search for m's, and each time
  562.     one was found, to find the longest possible strings of non-space
  563.     characters before and after it, and delete these.   (This is a silly
  564.     example, but I think the idea is clear.)
  565. Isn't worth doing - this is fast enough for most people in most cases.
  566.  
  567.          Something that I've seriously felt the need for is the
  568.     capability of searching for lines that satisfy more than one
  569.     condition.  If one just wants to locate such lines, one can
  570.     of course leave the editor and do a pipeline of two or
  571.     more greps; but it would be nice to be able to perform global
  572.     commands on such lines.
  573. You want the PWB "or" operator.  This is hard to put in - their code
  574. is really convoluted.
  575.  
  576.         Finally, any possibility of introducing the capability of searching
  577.     for patterns including embedded newlines, a la sed?
  578. Newlines aren't stored - the data structure is an array of lines.
  579. So this is nearly impossible.
  580.     Multiple windows, a la emacs?
  581. Would be easy after a rewrite, but impossible with current code.
  582. What you really want is a window manager, anyway, most of the time.
  583.  
  584.     ADDENDA
  585.          I logged in this morning on an adm3a at 300 baud to go over this
  586.     letter once more before sending it, and ran into another bug!  I had
  587.     done 15^D to get a large scroll despite the low speed, and at one point
  588.     I saw a line with a typo scrolling up.  So I noted its line-number, 402
  589.     and without waiting for the screen to stop moving typed something like
  590.     402Gfsrd.  What happened was that the change was made on line 407 rather
  591.     than 402 -- presumably the cursor was sent to where 402 had been when
  592.     the command was received... .
  593. Knowing the internals of vi, I'd say this is impossible.  It probably just
  594. screwed up your screen from line noise (or your terminal isn't truly full
  595. duplex), or you got the wrong line number.
  596.          Editing this letter this morning reminded me of another feature I
  597.     have thought would be desirable for editing on dumb terminals at low
  598.     speeds:  An option that would cause lines read from a file or typed
  599.     in at the bottom of the screen to appear double spaced, with @ signs
  600.     @
  601.     between them, such as one gets when one deletes a line on such a
  602.     @
  603.     terminal.  (I have faked this effect here, though the fake will not be
  604.     @
  605.     very successful if you have  se nu  or  se list  on.)  The point is that
  606.     @
  607.     editing operations that presently cause painfully slow screen-redrawings
  608.     would simply put material in in place of these fillers -- as happens
  609.     now when one is lucky enough to be adding material just above a place
  610.     where material was previously deleted.
  611. Again, it would cost less to buy a real terminal.  You can get one for $500
  612. or so now from Falco or Liberty or Zenith.
  613.  
  614. Thanks again for the input.
  615.  
  616.     Mark
  617.  
  618.  
  619.